﻿using Coldairarrow.Business;
using Coldairarrow.Entity;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers
{
    [Route("/Comment/[controller]/[action]")]
    public class Outbound_DetailsController : BaseApiController
    {
        #region DI

        public Outbound_DetailsController(IOutbound_DetailsBusiness outbound_DetailsBus)
        {
            _outbound_DetailsBus = outbound_DetailsBus;
        }

        IOutbound_DetailsBusiness _outbound_DetailsBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Outbound_Details>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _outbound_DetailsBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Outbound_Details> GetTheData(IdInputDTO input)
        {
            return await _outbound_DetailsBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 获取出库明细
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<OutDetailDTO>> GetDataTwo(PageInput<Outbound_DetailsDto> input)
        {
            return await _outbound_DetailsBus.GetDataTwo(input);
        }
        /// <summary>
        /// 获取出库统计
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<Outbound_Infor>> GetDatastationTwo(PageInput<Outbound_DetailsDto> input)
        {
            return await _outbound_DetailsBus.GetDatastationTwo(input);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Outbound_Details data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _outbound_DetailsBus.AddDataAsync(data);
            }
            else
            {
                await _outbound_DetailsBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _outbound_DetailsBus.DeleteDataAsync(ids);
        }
        /// <summary>
        /// 正向出库
        /// </summary>
        /// <param name="outbound"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task outBound(Outbound_Details outbound)
        {
            await _outbound_DetailsBus.outBound(outbound);
        }
        #endregion
    }
}